<#compress>
    <#assign actionname>${(action=='create')?string('新建','编辑')}</#assign>
    <@override name="title">${actionname}礼品</@override>
    <@override name="viewbody">
    <div class="row">
        <div class="col-md-12">
            <h3 class="page-title">
            ${actionname}礼品
                <small>${actionname}礼品.</small>
            </h3>
            <ul class="page-breadcrumb breadcrumb">
                <li>
                    <i class="fa fa-home"></i>
                    <a href="${ctx}/admin/home">首页</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a href="${ctx}/admin/gift/gift">礼品管理</a>
                    <i class="fa fa-angle-right"></i>
                </li>
                <li>
                    <a href="#">${actionname}- 礼品</a>
                </li>
            </ul>
        </div>
    </div>

    <div class="portlet box light-grey">
        <div class="portlet-title">
            <div class="caption">
                <i class="fa fa-gift"></i>礼品信息
            </div>
        </div>
        <div class="portlet-body">
            <form class="form-horizontal" action="${ctx}/admin/gift/gift/save" role="form" id="giftForm" method="post">
                <input name="gift.id" type="hidden" value="${gift.id!}"/>

                <div class="alert alert-danger display-hide">
                    <button class="close" data-close="alert"></button>
                    温馨提示：请输入正确的礼品信息！
                </div>
                <h3 class="form-section">礼品基本信息</h3>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="giftCode">礼品编号: <span class="required">*</span></label>

                    <div class="col-sm-10">
                        <input type="text" class="required form-control input-xlarge" placeholder="礼品编号"
                               name="gift.code" id="giftCode" value="${gift.code!}">
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="giftName">礼品名称: <span class="required">*</span></label>

                    <div class="col-sm-10">
                        <input type="text" class="required form-control input-xlarge" placeholder="礼品名称"
                               name="gift.name" id="giftName" value="${gift.name!}">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="giftCover">礼品封面: <span class="required">*</span></label>

                    <div class="col-sm-10">
                        <div class="fileinput fileinput-exists">
                            <input type="hidden" value="${gift.cover!}" id="giftCover" name="gift.cover">

                            <div class="fileinput-btn">
                                <span class="btn default btn-file">
                                    <span class="fileinput-new" id="cover_image_btn">&nbsp;</span>
                                </span>
                                <#if gift.cover??><a href="#" data-data="${gift.cover}"
                                                     class="btn default fileinput-exists fileinput-remove">删除图片</a></#if>
                            </div>
                            <div class="fileinput-preview thumbnail"
                                 style="width: 200px; height: 150px; line-height: 150px;">
                                <#if gift.cover??><a href="${ctx}${gift.cover}" class="thumbnail fancybox-button">
                                    <img class="" src="${ctx}${gift.cover?replace('.','.thumbnail.')}" alt="">
                                </a></#if>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="mo_prictures">礼品图片： </label>

                    <div class="col-md-10">
                        <p class="form-control-static">
                            <input id="prictureAttachmentUpload" type="file" class="btn">
                        </p>
                        <input type="hidden" id="mo_prictures" name="gift.picture" value="${gift.picture!}">
                        <ul class="list-inline blog-images" id="picture-grid">
                            <#if pics??>
                                <#list pics as pic>
                                    <li class="picture">
                                        <a href="${ctx}${pic}" class="fancybox-button" data-rel="fancybox-button">
                                            <img class="" src="${ctx}${pic?replace('.','.thumbnail.')}" alt="">
                                        </a>
                                        <a href="#" class="action" data-hook="remove_picture" data-target="#mo_prictures"
                                           data-data="${pic!}"><i class="fa fa-times"></i> </a>
                                    </li>
                                </#list>
                            </#if>
                        </ul>
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="description">礼品描述:</label>

                    <div class="col-sm-10">
                        <textarea rows="3" cols="5" id="description" class="limited form-control input-xlarge"
                                  name="gift.description"
                                  placeholder="请输入礼品描述">${gift.desciption!}</textarea>
                    </div>
                </div>
                <h3 class="form-section">礼品其他设置</h3>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="begin_time">开始时间: <span class="required">*</span></label>

                    <div class="col-sm-10">
                        <div class="input-group input-medium date form_datetime" data-link-field="begin_time">
                            <input class="required form-control" size="16" type="text" value="${gift.begin_time!}" name="gift.begin_time"
                                   id="begin_time">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                        </div>
                        <input type="hidden" id="gift.begin_time" name="begin_time" value="">
                    </div>
                </div>

                <div class="form-group">
                    <label class="col-sm-2 control-label" for="end_time">结束时间: <span class="required">*</span></label>

                    <div class="col-sm-9">
                        <div class="input-group input-medium date form_datetime"
                             data-link-field="end_time">
                            <input class="required form-control" size="16" type="text" value="${(gift.end_time)!}"
                                   name="gift.end_time" id="end_time">
                            <span class="input-group-addon"><span class="glyphicon glyphicon-remove"></span></span>
                            <span class="input-group-addon"><span class="glyphicon glyphicon-th"></span></span>
                        </div>
                        <input type="hidden" id="gift.end_time" name="end_time" value=""/>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="stock">库存: <span class="required">*</span></label>

                    <div class="col-sm-9">
                        <div id="stock_spinner">
                            <div class="input-group input-small">
                                <input type="text" class="required spinner-input form-control " id="stock" name="gift.stock"
                                       value="${gift.stock!}" maxlength="3" readonly>

                                <div class="spinner-buttons input-group-btn btn-group-vertical">
                                    <button type="button" class="btn spinner-up btn-xs blue">
                                        <i class="fa fa-angle-up"></i>
                                    </button>
                                    <button type="button" class="btn spinner-down btn-xs blue">
                                        <i class="fa fa-angle-down"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-sm-2 control-label" for="intergral">兑换积分: <span class="required">*</span></label>

                    <div class="col-sm-9">
                        <div id="intergral_spinner">
                            <div class="input-group input-small">
                                <input type="text" class="required spinner-input form-control " id="intergral" name="gift.intergral"
                                       value="${gift.intergral!}" maxlength="3" readonly>

                                <div class="spinner-buttons input-group-btn btn-group-vertical">
                                    <button type="button" class="btn spinner-up btn-xs blue">
                                        <i class="fa fa-angle-up"></i>
                                    </button>
                                    <button type="button" class="btn spinner-down btn-xs blue">
                                        <i class="fa fa-angle-down"></i>
                                    </button>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label">&nbsp;</label>

                    <div class="col-md-10">
                        <div class="checkbox-list">
                            <label> <input type="checkbox" name="hot" <#if gift.hot?? && gift.hot> checked="checked" </#if>> 热门 </label>
                        </div>

                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="activity_rule">活动规则:</label>

                    <div class="col-md-10">
                        <textarea class="form-control input-xlarge" placeholder="活动规则" id="activity_rule" name="gift.activity_rule"
                                  rows="3">${gift.activity_rule!}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="explanation">兑换说明:</label>

                    <div class="col-md-10">
                        <textarea class="form-control input-xlarge" placeholder="兑换说明" id="explanation" name="gift.explanation"
                                  rows="3">${gift.explanation!}</textarea>
                    </div>
                </div>
                <div class="form-group">
                    <label class="col-md-2 control-label" for="slogan">宣传语:</label>

                    <div class="col-md-10">
                        <input type="text" class="form-control input-xlarge" placeholder="宣传语"
                               name="gift.slogan" id="slogan" value="${gift.slogan!}">
                    </div>
                </div>

                <div class="form-actions text-right">

                    <a class="btn default yellow-stripe" href="${ctx}/admin/gift/gift"><i class="fa fa-arrow-circle-o-left"></i> 返回</a>
                    <input type="submit" value="保存" class="btn btn-primary">
                </div>
            </form>
        </div>

    </div>

    <script id="showpics-template" type="text/x-handlebars-template">
        <li class="picture">
            <a href="{{ctx}}{{preview}}" class="fancybox-button" data-rel="fancybox-button">
                <img class="" src="{{ctx}}{{data}}" alt="">
            </a>
            <a href="#" class="action" data-hook="remove_picture" data-target="#mo_prictures"
               data-data="{{preview}}"><i class="fa fa-times"></i> </a>
        </li>
    </script>
    </@override>

    <@override name="viewmodule">basic_gift_item</@override>
    <@extends name="../../_basic/main.ftl"></@extends>
</#compress>